<template>
    <div class="myBox">
        <div class="L"><img :src="business.avatar" /></div>
        <div class="C">
            <div class="tit">{{business.nickname ? business.nickname : business.mobile_text}}</div>
            <div class="sub" v-if="business.email">{{ business.email }}</div>
        </div>
    </div>
    <div class="clear"></div>
    <div class="allkbox"></div>
    <div class="myboxcon" @click="toProfile">
        <p>基本资料</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="toEmail" v-if="business.email && business.auth != 1">
        <p>邮箱认证</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="toAddress">
        <p>我的收货地址</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="toOrder">
        <p>我的订单</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="toCollection">
        <p>我的收藏</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="toRecord">
        <p>消费记录</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon">
        <p>充值记录</p>
        <img src="/assets/images/go.png">
    </div>
    <div class="myboxcon" @click="logout">
        <p>注销</p>
        <img src="/assets/images/go.png">
    </div>

    <div class="clear"></div>
    <div class="h54"></div>
    <div class="clear"></div>

    <Footer />
</template>
<script setup>
import Footer from '../../common/Footer.vue';
import { getCurrentInstance, ref } from 'vue';

const { proxy } = getCurrentInstance();
const business = ref(proxy.$cookies.get('business') ? proxy.$cookies.get('business') : {});

const toProfile = () => {
    proxy.$router.push('/business/base/profile');
    return;
}

const toAddress = () => {
    proxy.$router.push('/business/address/index');
    return;
}

const toEmail = () => {
    proxy.$router.push('/business/base/email');
    return;
}

const toCollection = () => {
    proxy.$router.push('/business/base/collection');
    return;
}

const toOrder = () => {
    proxy.$router.push('/product/order/index');
    return;
}

const toRecord = () => {
    proxy.$router.push('/business/base/record');
    return;
}

const logout = () => {
    
    if(proxy.$cookies.set('business',null)){
        proxy.$showNotify({
            type:'success',
            message:'退出成功',
            duration:1500,
            onClose:() => {
                proxy.$router.push('/business/base/login');
            }
        });

        return;
    }
}

</script>